package com.ischoolbar.programmer.dao;

/**
 * @Author lin
 **/

import com.ischoolbar.programmer.util.DbUtil;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class BaseDao {
    private DbUtil dbUtil = new DbUtil();
    public BaseDao() {
    }
    public void closeCon() {
        this.dbUtil.closeCon();
    }
    public ResultSet query(String sql) {
        try {
            PreparedStatement prepareStatement = this.dbUtil.getConnection().prepareStatement(sql);
            return prepareStatement.executeQuery();
        } catch (SQLException var3) {
            var3.printStackTrace();
            return null;
        }
    }
    public boolean update(String sql) {
        try {
            return this.dbUtil.getConnection().prepareStatement(sql).executeUpdate() > 0;
        } catch (SQLException var3) {
            var3.printStackTrace();
            return false;
        }
    }
    public Connection getConnection() {
        return this.dbUtil.getConnection();
    }
}

